package com.libbase.utils

import com.google.gson.Gson
import com.google.gson.GsonBuilder
import com.libbase.date.DateDeserializer
import com.libbase.date.DateSerializer
import java.util.*

class JsonUtils {
    companion object {
        val jsonBuilder: GsonBuilder by lazy(mode = LazyThreadSafetyMode.SYNCHRONIZED) {
            GsonBuilder()
                .registerTypeAdapter(genericType<Map<String, Any>>(), DataTypeAdapter())
                .registerTypeAdapter(Date::class.java, DateSerializer())
                .registerTypeAdapter(Date::class.java, DateDeserializer())
        }

        val json: Gson by lazy(mode = LazyThreadSafetyMode.SYNCHRONIZED) {
            GsonBuilder()
                .registerTypeAdapter(genericType<Map<String, Any>>(), DataTypeAdapter())
                .registerTypeAdapter(Date::class.java, DateSerializer())
                .registerTypeAdapter(Date::class.java, DateDeserializer())
                .create()
        }
    }
}